import Vue from 'vue'
import VueRouter from 'vue-router'
import Douban from '@/views/Douban.vue'
import Home from '@/views/Home.vue'

Vue.use(VueRouter)

const routes = [
	{
	  path: '/Douban',
	  component: Douban,
		children:[
			{
				path: '/Douban/home',
				name: 'Home',
				component: Home
			},
			{
				path: '/Douban/my',
				name: 'My',
				component: () => import('@/views/My.vue'),
			},
			{
				path: '/Douban/bookcase',
				name: 'Bookcase',
				component: () => import('@/views/Bookcase.vue'),
			},
			{
				path: '/Douban',
				redirect:'/Douban/home'
			},
		]
	},
	
	
 //  {
 //    path: '/bookcase',
 //    name: 'Bookcase',
 //    component: () => import('@/views/Bookcase.vue'),
	// // 是否是要拦截的页面
	// meta:{
	// 	isRequery:true
	// }
 //  },
 
 
 
  // {
  //   path: '/detail',
  //   name: 'Detail',
  //   component: () => import('@/views/home/Detail.vue'),
  // },
  
	// 搜索页面的  书籍详情
	{
	  path: '/details',
	  name: 'Details',
	  component: () => import('@/views/home/Details.vue'),
	},
	// home主页书籍详情
	{
	  path: '/ebookDetail/:ebookId',
	  name: 'EbookDetail',
	  component: () => import('@/views/home/EbookDetail.vue'),
	},
	
	
	// 连载
	{
	  path: '/columns',
	  name: 'Columns',
	  component: () => import('@/views/home/Columns.vue'),
	},
	// 短篇
	{
	  path: '/essays',
	  name: 'Essays',
	  component: () => import('@/views/home/Essays.vue'),
	},
	// 连载  短篇  里边的查看更多
	{
		path: '/ColumnsMore',
		name:'ColumnsMore',
		component: () => import('@/views/home/ColumnsMore.vue'),
	},
	
	// home首页轮播中查看相关更多
	{
		path:'/category/:name',
		name:'Category',
		component: () => import('@/views/home/Category.vue'),
	},
	
  // 路由重定向，即刚进页面的默认显示的页面
  {
  	path:"*",
  	redirect:"/Douban",
  }
  
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})


// 注册前置全局守卫（拦截器）
router.beforeEach((to,from,next)=>{
	next()
	// if(to.meta.isRequery){
	// 	if(localStorage.getItem('token')){
	// 		next()
	// 	}else{
	// 		next('/login')
	// 		sessionStorage.setItem('path',to.path);
	// 	}
	// }else{
	// 	next()
	// }
})

export default router
